from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
from time import sleep

class Test_Ranzhi:
    # def __init__(self,driver=None):
    #     self.driver = None


    # def test_driver_ex(self):
    #     self.driver = webdriver.Chrome()
    #
    # def test_get_url(self):
    #     self.driver.get("http://192.168.1.138/ranzhi/www/sys/user-login.html")
    #     self.driver.maximize_window()

    def test_login_moudle(self):
        driver = webdriver.Firefox()
        driver.get("http://192.168.1.138/ranzhi/www/sys/user-login.html")
        driver.maximize_window()
        WebDriverWait(driver, 10).until(expected_conditions.presence_of_element_located((By.CLASS_NAME, "btn")))
        driver.find_element(By.CLASS_NAME, "btn").click()

        WebDriverWait(driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "account")))
        driver.find_element(By.ID, "account").send_keys("admin")

        WebDriverWait(driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "password")))
        driver.find_element(By.ID, "password").send_keys("123456")

        WebDriverWait(driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "keepLoginon")))
        driver.find_element(By.ID, "keepLoginon").click()

        WebDriverWait(driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "submit")))
        driver.find_element(By.ID, "submit").click()

        WebDriverWait(driver, 10).until(expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='s-menu-superadmin']/button")))
        driver.find_element(By.XPATH, "//*[@id='s-menu-superadmin']/button").click()
        return driver

    def test_add_members(self):
        self.driver = self.test_login_moudle()
        frame = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "iframe-superadmin")))
        self.driver.switch_to.frame(frame)
        WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a")))
        self.driver.find_element(By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a").click()
        WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]")))
        self.driver.find_element(By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]").click()
        WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "genderm")))
        self.driver.find_element(By.ID, "genderm").click()

        WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "role")))
        elements = self.driver.find_element(By.ID, "role")
        obj_ele = Select(elements)
        obj_ele.select_by_value("support")
        data1 = {
            "account":"dsa",
            "realname":"zsdd",
            "password1":"2641278677",
            "password2":"2641278677",
            "email":"25" + "@qq.com",
        }
        for key,value in data1.items():
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, key)))
            self.driver.find_element(By.ID, key).send_keys(value)
        WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "submit")))
        self.driver.find_element(By.ID, "submit").click()
        self.driver.quit()


    def test_add_members_test_account1(self):   #用户名输入空的字符
        self.driver = self.test_login_moudle()
        try:
            frame = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "iframe-superadmin")))
            self.driver.switch_to.frame(frame)
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a")))
            self.driver.find_element(By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located(
                (By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]")))
            self.driver.find_element(By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "genderm")))
            self.driver.find_element(By.ID, "genderm").click()

            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "role")))
            elements = self.driver.find_element(By.ID, "role")
            obj_ele = Select(elements)
            obj_ele.select_by_value("support")
            data1 = {
                "account": "",
                "realname": "zsdd",
                "password1": "2641278677",
                "password2": "2641278677",
                "email": "23" + "@qq.com",
            }
            for key, value in data1.items():
                WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, key)))
                self.driver.find_element(By.ID, key).send_keys(value)
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "submit")))
            self.driver.find_element(By.ID, "submit").click()
            WebDriverWait(self.driver,10).until(expected_conditions.presence_of_element_located((By.ID,"accountLabel")))
            text = self.driver.find_element(By.ID, "accountLabel").text
            self.driver.quit()
            assert text == "","输入空的用户名，进行添加，添加失败！"  #用户名不能为空。;用户名应当为字母或数字的组合，至少三位
            # self.driver.quit()
            # return self.driver
            # sleep(2)
        except Exception as e:
            print(e)
            # raise e   #想处理异常就抛出异常

    def test_add_members_test_account2(self):    #用户名输入两个字符
        self.driver = self.test_login_moudle()
        try:
            frame = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "iframe-superadmin")))
            self.driver.switch_to.frame(frame)
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a")))
            self.driver.find_element(By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located(
                (By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]")))
            self.driver.find_element(By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "genderm")))
            self.driver.find_element(By.ID, "genderm").click()

            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "role")))
            elements = self.driver.find_element(By.ID, "role")
            obj_ele = Select(elements)
            obj_ele.select_by_value("support")
            data1 = {
                "account": "ds",
                "realname": "zsdd",
                "password1": "2641278677",
                "password2": "2641278677",
                "email": "23" + "@qq.com",
            }
            for key, value in data1.items():
                WebDriverWait(self.driver, 10).until(
                    expected_conditions.presence_of_element_located((By.ID, key)))
                self.driver.find_element(By.ID, key).send_keys(value)
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "submit")))
            self.driver.find_element(By.ID, "submit").click()
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.ID, "accountLabel")))
            text = self.driver.find_element(By.ID, "accountLabel").text
            self.driver.quit()
            assert text == "", "输入两位用户名，进行添加，添加失败"  # 用户名不能为空。;用户名应当为字母或数字的组合，至少三位
            # self.driver.quit()
        except Exception as e:
            print(e)

    def test_add_members_test_realname(self):  # 输入空的真实姓名
        self.driver = self.test_login_moudle()
        try:
            frame = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "iframe-superadmin")))
            self.driver.switch_to.frame(frame)
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a")))
            self.driver.find_element(By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located(
                (By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]")))
            self.driver.find_element(By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "genderm")))
            self.driver.find_element(By.ID, "genderm").click()

            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "role")))
            elements = self.driver.find_element(By.ID, "role")
            obj_ele = Select(elements)
            obj_ele.select_by_value("support")
            data1 = {
                "account": "dsa",
                "realname": "",
                "password1": "2641278677",
                "password2": "2641278677",
                "email": "23" + "@qq.com",
            }
            for key, value in data1.items():
                WebDriverWait(self.driver, 10).until(
                    expected_conditions.presence_of_element_located((By.ID, key)))
                self.driver.find_element(By.ID, key).send_keys(value)
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "submit")))
            self.driver.find_element(By.ID, "submit").click()
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.ID, "realnameLabel")))
            text = self.driver.find_element(By.ID, "realnameLabel").text
            self.driver.quit()
            assert text == "", "输入空的真实姓名，进行添加，添加失败！"  # 真实姓名不能为空。
            # self.driver.quit()
        except Exception as e:
            print(e)

    def test_add_members_test_charcter(self):  #输入空的角色
        self.driver = self.test_login_moudle()
        try:
            frame = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "iframe-superadmin")))
            self.driver.switch_to.frame(frame)
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a")))
            self.driver.find_element(By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located(
                (By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]")))
            self.driver.find_element(By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "genderm")))
            self.driver.find_element(By.ID, "genderm").click()

            # WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "role")))
            # elements = self.driver.find_element(By.ID, "role")
            # obj_ele = Select(elements)
            # obj_ele.select_by_value("support")
            data1 = {
                "account": "dsa",
                "realname": "zsdd",
                "password1": "2641278677",
                "password2": "2641278677",
                "email": "23" + "@qq.com",
            }
            for key, value in data1.items():
                WebDriverWait(self.driver, 10).until(
                    expected_conditions.presence_of_element_located((By.ID, key)))
                self.driver.find_element(By.ID, key).send_keys(value)
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "submit")))
            self.driver.find_element(By.ID, "submit").click()
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.ID, "roleLabel")))
            text = self.driver.find_element(By.ID, "roleLabel").text
            self.driver.quit()
            assert text == "", "输入空的角色，进行添加，添加失败！"  # 角色不能为空。
            # self.driver.quit()
        except Exception as e:
            print(e)

    def test_add_members_test_password1(self):  #输入空的密码1
        self.driver = self.test_login_moudle()
        try:
            frame = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "iframe-superadmin")))
            self.driver.switch_to.frame(frame)
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a")))
            self.driver.find_element(By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located(
                (By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]")))
            self.driver.find_element(By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "genderm")))
            self.driver.find_element(By.ID, "genderm").click()

            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "role")))
            elements = self.driver.find_element(By.ID, "role")
            obj_ele = Select(elements)
            obj_ele.select_by_value("support")
            data1 = {
                "account": "dsa",
                "realname": "zsdd",
                "password1": "",
                "password2": "2641278677",
                "email": "23" + "@qq.com",
            }
            for key, value in data1.items():
                WebDriverWait(self.driver, 10).until(
                    expected_conditions.presence_of_element_located((By.ID, key)))
                self.driver.find_element(By.ID, key).send_keys(value)
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "submit")))
            self.driver.find_element(By.ID, "submit").click()
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.ID, "password1Label")))
            text = self.driver.find_element(By.ID, "password1Label").text
            self.driver.quit()
            assert text == "", "输入空的密码1，进行添加，添加失败！"  # 密码1不能为空。
            # self.driver.quit()
        except Exception as e:
            print(e)

    def test_add_members_test_password2(self):   #输入不一样的密码信息
        self.driver = self.test_login_moudle()
        try:
            frame = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "iframe-superadmin")))
            self.driver.switch_to.frame(frame)
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a")))
            self.driver.find_element(By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located(
                (By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]")))
            self.driver.find_element(By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "genderm")))
            self.driver.find_element(By.ID, "genderm").click()

            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "role")))
            elements = self.driver.find_element(By.ID, "role")
            obj_ele = Select(elements)
            obj_ele.select_by_value("support")
            data1 = {
                "account": "dsa",
                "realname": "zsdd",
                "password1": "2641278677",
                "password2": "654654654",
                "email": "23" + "@qq.com",
            }
            for key, value in data1.items():
                WebDriverWait(self.driver, 10).until(
                    expected_conditions.presence_of_element_located((By.ID, key)))
                self.driver.find_element(By.ID, key).send_keys(value)
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "submit")))
            self.driver.find_element(By.ID, "submit").click()
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.ID, "password1Label")))
            text = self.driver.find_element(By.ID, "password1Label").text
            self.driver.quit()
            assert text == "", "输入与密码1不同的密码2，进行添加，添加失败！"  # 密码2必须与密码1相一致。
            # self.driver.quit()
        except Exception as e:
            print(e)

    def test_add_members_test_email(self):  #输入空的emial
        self.driver = self.test_login_moudle()
        try:
            frame = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "iframe-superadmin")))
            self.driver.switch_to.frame(frame)
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a")))
            self.driver.find_element(By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located(
                (By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]")))
            self.driver.find_element(By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "genderm")))
            self.driver.find_element(By.ID, "genderm").click()

            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "role")))
            elements = self.driver.find_element(By.ID, "role")
            obj_ele = Select(elements)
            obj_ele.select_by_value("support")
            data1 = {
                "account": "dsa",
                "realname": "zsdd",
                "password1": "2641278677",
                "password2": "2641278677",
                "email": "",
            }
            for key, value in data1.items():
                WebDriverWait(self.driver, 10).until(
                    expected_conditions.presence_of_element_located((By.ID, key)))
                self.driver.find_element(By.ID, key).send_keys(value)
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "submit")))
            self.driver.find_element(By.ID, "submit").click()
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.ID, "emailLabel")))
            text = self.driver.find_element(By.ID, "emailLabel").text
            self.driver.quit()
            assert text == "", "输入空的邮箱，进行添加，添加失败！"  # 必须输入邮箱。
            # self.driver.quit()
        except Exception as e:
            print(e)

    def test_add_members_test_email2(self):  #输入不规范的的emial
        self.driver = self.test_login_moudle()
        try:
            frame = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "iframe-superadmin")))
            self.driver.switch_to.frame(frame)
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a")))
            self.driver.find_element(By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located(
                (By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]")))
            self.driver.find_element(By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "genderm")))
            self.driver.find_element(By.ID, "genderm").click()

            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "role")))
            elements = self.driver.find_element(By.ID, "role")
            obj_ele = Select(elements)
            obj_ele.select_by_value("support")
            data1 = {
                "account": "dsa",
                "realname": "zsdd",
                "password1": "2641278677",
                "password2": "2641278677",
                "email": "264124658",
            }
            for key, value in data1.items():
                WebDriverWait(self.driver, 10).until(
                    expected_conditions.presence_of_element_located((By.ID, key)))
                self.driver.find_element(By.ID, key).send_keys(value)
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "submit")))
            self.driver.find_element(By.ID, "submit").click()
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.ID, "emailLabel")))
            text = self.driver.find_element(By.ID, "emailLabel").text
            self.driver.quit()
            assert text == "", "输入不规范的邮箱，进行添加，添加失败！"  # 必须输入邮箱。
            # self.driver.quit()
        except Exception as e:
            print(e)

    def test_add_members_test_email3(self):  #输入已经存在的邮箱
        self.driver = self.test_login_moudle()
        try:
            frame = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "iframe-superadmin")))
            self.driver.switch_to.frame(frame)
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a")))
            self.driver.find_element(By.XPATH, "//*[@id='mainNavbar']/ul/li[2]/a").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located(
                (By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]")))
            self.driver.find_element(By.XPATH, "/html/body/div/div/div/div[1]/div/div[2]/a[1]").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "genderm")))
            self.driver.find_element(By.ID, "genderm").click()

            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "role")))
            elements = self.driver.find_element(By.ID, "role")
            obj_ele = Select(elements)
            obj_ele.select_by_value("support")
            data1 = {
                "account": "dsa",
                "realname": "zsdd",
                "password1": "2641278677",
                "password2": "2641278677",
                "email": "2641278677@qq.com",
            }
            for key, value in data1.items():
                WebDriverWait(self.driver, 10).until(
                    expected_conditions.presence_of_element_located((By.ID, key)))
                self.driver.find_element(By.ID, key).send_keys(value)
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "submit")))
            self.driver.find_element(By.ID, "submit").click()
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.ID, "emailLabel")))
            text = self.driver.find_element(By.ID, "emailLabel").text
            self.driver.quit()
            assert text == "", "输入已经存在的邮箱，进行添加，添加失败！"  # 输入存在的邮箱。
            # self.driver.quit()
        except Exception as e:
            print(e)


    def test_add_new_customer(self):
        self.driver = self.test_login_moudle()
        # 添加客户
        self.driver.switch_to.parent_frame()
        WebDriverWait( self.driver, 10).until(expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='s-menu-1']/button")))
        self.driver.find_element(By.XPATH, "//*[@id='s-menu-1']/button").click()
        frame1 = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "iframe-1")))
        self.driver.switch_to.frame(frame1)
        WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='mainNavbar']/ul/li[4]/a")))
        self.driver.find_element(By.XPATH, "//*[@id='mainNavbar']/ul/li[4]/a").click()
        WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='menuActions']/a")))
        self.driver.find_element(By.XPATH, "//*[@id='menuActions']/a").click()
        data = {
            "name":"张没钱",
            "contact":"张嘉龙",
            "phone":"1984568321",
            "email":"2641278677@qq.com",
            "qq":"2641278677",
            "depositor":"asdadadsada",
            "addresstitle":"西安市",
            "addresslocation":"新学苑",
            "intension":"无"
        }
        for key,value in data.items():
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, key)))
            self.driver.find_element(By.ID, key).send_keys(value)
        WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "public")))
        self.driver.find_element(By.ID, "public").click()
        list = ["type","size","status","level"]
        for str_ in list:
            ele = self.driver.find_element(By.ID, "type")
            diaoyong_obj = Select(ele)
            diaoyong_obj.select_by_index(2)
        WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "submit")))
        self.driver.find_element(By.ID, "submit").click()

        WebDriverWait(self.driver, 10).until(
            expected_conditions.presence_of_element_located((By.XPATH, '//*[@id="duplicateError"]/div/button[1]')))
        self.driver.find_element(By.XPATH, '//*[@id="duplicateError"]/div/button[1]').click()
        self.driver.quit()


    def test_add_new_customer_None(self):
        self.driver = self.test_login_moudle()
        # 添加客户
        try:
            self.driver.switch_to.parent_frame()
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='s-menu-1']/button")))
            self.driver.find_element(By.XPATH, "//*[@id='s-menu-1']/button").click()
            frame1 = WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.ID, "iframe-1")))
            self.driver.switch_to.frame(frame1)
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='mainNavbar']/ul/li[4]/a")))
            self.driver.find_element(By.XPATH, "//*[@id='mainNavbar']/ul/li[4]/a").click()
            WebDriverWait(self.driver, 10).until(
                expected_conditions.presence_of_element_located((By.XPATH, "//*[@id='menuActions']/a")))
            self.driver.find_element(By.XPATH, "//*[@id='menuActions']/a").click()
            data = {
                "name": "张有钱",
                "contact": "",
                "phone": "1984568321",
                "email": "2641278677@qq.com",
                "qq": "2641278677",
                "depositor": "asdadadsada",
                "addresstitle": "西安市",
                "addresslocation": "新学苑",
                "intension": "无"
            }
            for key, value in data.items():
                WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, key)))
                self.driver.find_element(By.ID, key).send_keys(value)
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "public")))
            self.driver.find_element(By.ID, "public").click()
            list = ["type", "size", "status", "level"]
            for str_ in list:
                ele = self.driver.find_element(By.ID, "type")
                diaoyong_obj = Select(ele)
                diaoyong_obj.select_by_index(2)
            self.driver.execute_script("window.scrollTo(0,400)")
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "submit")))
            self.driver.find_element(By.ID, "submit").click()
            WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.ID, "continueSubmit"))).click()
            # self.driver.find_element(By.XPATH, '//*[@id="duplicateError"]/div/button[1]').click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.ID, "submit")))
            # self.driver.find_element(By.ID, "submit").click()
            WebDriverWait(self.driver, 10).until(expected_conditions.presence_of_element_located((By.XPATH, '//*[@id="contactLabel"]')))
            text  = self.driver.find_element(By.XPATH, '//*[@id="contactLabel"]').text
            self.driver.quit()
            assert text == "" , "输入联系人为空，添加失败"      #输入联系人为空
            # self.driver.quit()
        except Exception as e:
            print(e)



# if __name__ == '__main__':
#     test = Test_Ranzhi()
#     test.test_add_members()
#     test.test_add_members_test_account1()
#     test.test_add_members_test_account2()
#     test.test_add_members_test_realname()
#     test.test_add_members_test_password1()
#     test.test_add_members_test_password2()
#     test.test_add_members_test_email()
#     test.test_add_members_test_email2()
#     test.test_add_members_test_email3()
#     test.test_add_new_customer()
#     test.test_add_new_customer_None()

